regular over enums in 2.9.0

26 views
Skip to first unread message

Mikael Zayenz Lagerkvist

unread,
Feb 26, 2025, 11:16:13 AMFeb 26
to MiniZinc
Hi,

As a very simplified example, I have a model that contains the following 

include "globals.mzn";
enum Days = {Mon, Tue, Wed, Thu, Fri, Sat, Sun};
set of int: Weeks = 1..3;
enum Activity = {Work, Free};
array[Weeks, Days] of var Activity: schedule;
constraint forall (w in Weeks) (
    regular(schedule[w, ..], "Free* [^Free]+ Free*")
);
solve satisfy;

The gist is that for each week, the work is concentrated into one group. With 2.9.0, the IDE warns for the regular call, indicating ""Implicit coercion of enums to integers is deprecated and will be removed in a future version. Use the explicit coercion function enum2int instead"

Changing the constraint to
    regular(enum2int(schedule[w, ..]), "Free* [^Free]+ Free*")
works as expected. However this _looks_ wrong as the regular expression is expressed over the enum variants.

Should I add the enum2int call in my regular-usages, or will there be a enum-variant of regular as well?

Cheers,
Mikael


Cyderize

unread,
Feb 26, 2025, 11:21:34 AMFeb 26
to MiniZinc
There should be an enum version - I must have missed this when updating the library. This will be fixed in the next release.

Mikael Zayenz Lagerkvist

unread,
Feb 26, 2025, 12:16:16 PMFeb 26
to mini...@googlegroups.com
Sounds good. Regular with enum variables is such a nice abstraction
for scheduling problems!

Cheers,
Mikael
> --
> You received this message because you are subscribed to a topic in the Google Groups "MiniZinc" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/minizinc/L7wX191Og0g/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to minizinc+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/minizinc/e553a035-6503-4ab3-9a3c-fdab342e6cc6n%40googlegroups.com.



--
Mikael Zayenz Lagerkvist
Reply all
Reply to author
Forward
0 new messages